package com.lindroy.androidplayer.logic.network.base.http

import com.lindroy.androidplayer.logic.network.base.BaseResponse
import com.lindroy.androidplayer.logic.network.enums.HttpError

/**
 * @author Lin
 * @date 2021/10/15
 * @function
 */
open class RequestException(
    val code: Int? = 0,
    val errorMsg: String? = "",
    val error: String? = null
) : Exception() {

    constructor(response: BaseResponse<*>) : this(
        response.errorCode,
        response.errorMsg,
        response.errorMsg
    )

    constructor(httpError: HttpError, error: String?) : this(
        httpError.code,
        httpError.message,
        error
    )

    override fun toString(): String {
        return "RequestException(code=$code, errorMsg=$errorMsg, error=$error)"
    }


}

class NotLoginException(errorCode: Int, msg: String) : RequestException(errorCode, msg, msg)

/**
 * 用于 Paging3 请求列表时显示空视图布局
 */
class EmptyDataException : RequestException()